<%@ page language="java" import="java.sql.*" contentType="text/html;charset=utf-8" %>

<HTML>
<HEAD>
<TITLE>▒▒ 게시판 ▒▒</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
  .table {font-size:9pt; font-family : 돋움 ;font-weight:bold;color:white;background:#6699CC; }
a {text-decoration: none; }
  td	{ font-size : 10pt ; font-family : 돋움 ; font-decoration : none ;}
  font	{ font-size : 10pt ; font-family : 돋움 ; font-decoration : none ; }
  #title{ font-size : 10pt ; font-family : 돋움 ; font-decoration : none ; font-weight : bold ; color : ffffff ;}
 .dform { font-family: 돋움 ; font-size:10pt;color:white;background:#6699CC;}
 .ldTable { border-bottom:#636363 solid 1px;border-color:white; padding-top:5px; padding-bottom:5px; padding-left:3px;
            padding-right:3px; font-size:9pt}
-->
</style>

</HEAD>
<BODY bgcolor="#FFFFFF">

<CENTER>
<FONT size=2><B> 게시판 글목록 </B></FONT>
</CENTER>
<HR>

<p align="center"><br>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="600">
    <tr>
        <td bgcolor="#FFFFFF">
        
        <table border="0" cellpadding="2" cellspacing="1" width="600">
        	<tr>
            	<th width="8%" align="center" bgcolor="#8EA2FF">
            		<p><font size="2" color=white>번호</font>
            	</th>            		
                <th width="48%" align="center" bgcolor="#8EA2FF">
                	<p><font size="2" color=white>제 목</font>
                </th>
                <th width="15%" align="center" bgcolor="#8EA2FF">
                	<p><font size="2" color=white>글쓴이</font>
                </th>
                <th width="15%" align="center" bgcolor="#8EA2FF">
                	<p><font size="2" color=white>날짜</font>
                </th>
                <th width="8%" align="center" bgcolor="#8EA2FF">
                	<p><font size="2" color=white>조회</font>
                </th>
            </tr>

<%	
	String DB_URL = "jdbc:mysql://localhost:3306/bbs";
	String DB_USER = "root";
	String DB_PASSWORD = "root";

	Connection conn = null;
	Statement stmt1 = null, stmt2=null;
	ResultSet result1 = null, result2 = null;

	String query1 = "select max(idx) from guest";
	String query2 = "";

	String sName, sEmail, sTitle, sContent, sMoment, sPwd, sTo;

	int idx =0, hit=0;


	Class.forName("com.mysql.jdbc.Driver");
	conn=DriverManager.getConnection(DB_URL, DB_USER, DB_PASSWORD);
	stmt1 = conn.createStatement();
	result1 = stmt1.executeQuery(query1);

	

	stmt2 = conn.createStatement();
	query2="SELECT IDX,NAME,EMAIL,TITLE,CONTENT,date_format(MOMENT,'%Y-%m-%e'),PASSWORD,HIT FROM GUEST WHERE IDX >= "+0+" AND IDX <= "+100+" ORDER BY IDX DESC";
	result2 = stmt2.executeQuery(query2);
  	
	while(result2.next()) {
		idx = result2.getInt(1);
		sName = result2.getString(2);
		sEmail = result2.getString(3);
		sTitle = result2.getString(4);
		sContent = result2.getString(5);
		sMoment = result2.getString(6);
		sPwd = result2.getString(7);
		hit = result2.getInt(8);

		if(!sEmail.equals("")){
			sTo="<A href=mailto:"+sEmail+">"+sName+"</A>";
		}else{
			sTo=sName;
		}
 
%>
                
                <tr>
                    <td align="center" bgcolor="#F6F6F6">
                    	<p><font size="2"><%=idx%></font>
                    </td>
                    <td width="364" align="left" bgcolor="#F6F6F6">                    	
                    	&nbsp;&nbsp;
                    	<a href="view.jsp?idx=<%=idx%>">
                    	<font size="2"><%=sTitle%></font>
                    	</a>
                    </td>
                    <td width="94" align="center" bgcolor="#F6F6F6"><p><font
                         size="2"><%=sTo%></font></td>
                    <td width="114" align="center" bgcolor="#F6F6F6"><p><font
                         size="2"><%=sMoment%></font></td>
                    <td align="center" bgcolor="#F6F6F6"><p><font size="2"><%=hit%></font></td>
                </tr>
<%	
	}
	stmt2.close();
	conn.close();
 
%>
            </table></td>
    </tr>

</table>
	
</div>

<br>

<p align="center">
  <table>
	  <tr>
	  	<td>
 		
	  	</td>
	  	<td>&nbsp;&nbsp;</td>
	  	<td>
	  		<a href="write.jsp"><img src="image/accept.gif" border="0"></a>	  <!-- 여기 -->		
	  	</td>
	  	<td>&nbsp;&nbsp;</td>
	  	<td>
 		
	  	</td>	  	
	  </tr>
  </table>
  </p>

</BODY>

</HTML>
